﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Xml;
using System.Xml.XPath;

namespace SaaS
{
    /// <summary>
    /// Summary description for DataUpdate
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class DataUpdate : System.Web.Services.WebService
    {

        [WebMethod]
        public string edit(string newVal, string colId, string xmlStr)
        {            
            XmlDocument xd = new XmlDocument();
            xd.LoadXml(xmlStr);
            string xp = "//col[./columnID='" + colId + "']/coldata";
            XmlNode xn = xd.SelectSingleNode(xp);
            string oldValue = xn.InnerText;
            xn.InnerText = newVal;

            System.IO.StringWriter sw = new System.IO.StringWriter();
            XmlTextWriter xw = new XmlTextWriter(sw);
            xd.WriteTo(xw);
            string newXmlStr = sw.ToString();

            return newXmlStr;
        }
    }
}
